package com.zmc.shard.controller;

import com.zmc.shard.domain.CashConfig;
import com.zmc.shard.domain.CashOrder;
import com.zmc.shard.domain.CashUser;
import com.zmc.shard.service.CashConfigService;
import com.zmc.shard.service.CashOrderService;
import com.zmc.shard.service.CashUserService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.IntStream;

@RestController
@RequestMapping("order/")
public class OrderController {

    @Resource
    private CashOrderService cashOrderService;
    @Resource
    private CashConfigService cashConfigService;
    @Resource
    private CashUserService cashUserService;

    @RequestMapping("save")
    public String save(){
        IntStream.range(0,100).forEach(i->{
            CashOrder cashOrder = new CashOrder();
            cashOrder.setApplyId("abc");
            cashOrder.setApplyStatus(i + "");
            cashOrder.setApplyStatusMessage("success");
            cashOrder.setCreateBy("aaa");
            cashOrder.setName("张三" + i);
            cashOrder.setPhone("1888888" + i);
            cashOrder.setNum("400000000000000000");
            cashOrderService.save(cashOrder);
        });
        CashConfig config = new CashConfig();
        config.setOrderId("abc");
        cashConfigService.save(config);
        return "ok";
    }

    @RequestMapping("get")
    public String get(){
        cashConfigService.testConfigAndOrder();
        return "ok";
    }
}
